// 引入 request 文件
import request from './index.js'
// 获取分类列表
export const getCategoryList = (data) => {
	return request.get("/user/categories", data);
}
// 获取商品列表
export const getProducts = (id) => {
	return request.get("/user/products", {
		category_id: id
	});
}
// 登录
export const getLogin = (code) => {
	return request.post("/user/login", {
		code
	});
}
// 获取用户个人信息
export const getUserDetail = () => {
	return request.get("/user/detail");
}
// 修改用户个人信息
export const getUpdateUserDetail = (data) => {
	return request.post("/user/update", data);
}
// 获取购物车列表
export const getShoppingCartLists = (data) => {
	return request.get("/user/shopping", data);
}
// 修改购物车数据
export const updateShoppingCart = (data) => {
	return request.post("/user/shopping/update", data, {
		type: 'application/x-www-form-urlencoded'
	});
}
// 清空购物车
export const delShoppingCart = (data) => {
	return request.delete("/user/shopping/del/" + data, {
		type: 'application/x-www-form-urlencoded'
	});
}
// 获取广告图
export const getBannerList = (data) => {
	return request.get("/user/products/banner", data);
}
// 插入地址
export const insertAddressBook = (data) => {
	return request.post("/user/addressBook/insert", data);
}
// 修改地址
export const updateAddressBook = (data) => {
	return request.put("/user/addressBook", data);
}
// 获取默认地址
export const getDefaultAddressBook = (data) => {
	return request.get("/user/addressBook/default");
}
// 删除地址
export const delAddressBook = (data) => {
	return request.get("/user/addressBook/del", data);
}
// 获取用户所有地址
export const getAllAddressBook = (data) => {
	return request.get("/user/addressBook/list");
}
// 设置地址为默认值
export const setDefaultAddressBook = (data) => {
	return request.put("/user/addressBook/default", data);
}
// 依据id查地址详情
export const getByIdAddressBook = (id) => {
	return request.get("/user/addressBook/" + id);
}
// 用户下单
export const payOrder = (data) => {
	return request.post("/user/order/submit", data)
}
// 用户订单列表获取
export const getOrderList = (data) => {
	return request.get("/user/order/list", data)
}
// 获取订单详情
export const getOrderDetail = (data) => {
	return request.get("/user/order/detail/" + data)
}
// 再来一单
export const againOrder = (data) => {
	return request.post("/user/order/again/" + data)
}
// 取消订单
export const cancelOrder = (data) => {
	return request.post("/user/order/cancel", data)
}
// 获取店铺信息
export const getShopDetail = (data) => {
	return request.get('/user/shop/detail', data)
}
// 获取优惠券列表
export const getCouponList = (params) => {
	return request.get("/user/coupon/list", params);
};